package wxdb.parse.absyn;

import java.util.HashMap;

import wxdb.query.*;
public class UpdtCls extends Exp{
	public FldExp fldExp;
	public RValue rVal;
	HashMap<String,Expression> namevalue = new HashMap<String,Expression>();
	
	public UpdtCls(int p, FldExp f,RValue r){
		pos = p;
		fldExp = f; 
		rVal = r;
		
		String fld = (((NameExp)((NameFldExp)fldExp).nameExp).fieldname).toString();
		Expression newval;
		
		RValExprs rve = (RValExprs)rVal;
		ValExp ve = (ValExp)rve.exp;
		Val v = ve.val;
		if(v instanceof FloatVal){
			Constant c = new FloatConstant(((FloatVal) v).fltval);
			newval = new ConstantExpression(c);
		}else if(v instanceof IntVal){
			Constant c = new IntConstant(((IntVal) v).ival);
			newval = new ConstantExpression(c);
		}else{
			Constant c = new StringConstant(((StringVal) v).sval);
			newval = new ConstantExpression(c);
		}
		namevalue.put(fld, newval);
	}
	
	HashMap<String,Expression> getNameValue(){
		return namevalue;
	}
}
